﻿@model StoryTimeline.Models.Fact

@{
    ViewBag.Title = "Edit";
}

<h2>Edit</h2>


@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <h4>Fact</h4>
        <hr />
        @Html.ValidationSummary(true)
        @Html.HiddenFor(model => model.Id)

        <div class="form-group">
            @Html.LabelFor(model => model.Text, new {@class = "control-label col-md-2"})
            <div class="col-md-10">
                @Html.EditorFor(model => model.Text)
                @Html.ValidationMessageFor(model => model.Text)
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Date, new {@class = "control-label col-md-2"})
            <div class="col-md-10">
                @Html.EditorFor(model => model.Date)
                @Html.ValidationMessageFor(model => model.Date)
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Rate, new {@class = "control-label col-md-2"})
            <div class="col-md-10">
                @Html.EditorFor(model => model.Rate)
                @Html.ValidationMessageFor(model => model.Rate)
            </div>
        </div>
        
        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <table>
                    <tr>
                    @{
                        int cnt = 0;
                        List<StoryTimeline.ViewModels.StoryFactData> stories = ViewBag.Stories;

                        foreach (var story in stories)
                        {
                            if (cnt++%3 == 0)
                            {
                                @:</tr><tr>
                            }
                            @:<td>
                    <input type="checkbox"
                           name="selectedStories"
                           value="@story.StoryID"
                           @(Html.Raw(story.Assigned ? "checked=\"checked\"" : "")) />
                            @story.StoryID
                            @:  @story.Title
                            @:</td>
                        }
                        @:</tr>
                    }
                </table>
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Save" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
